import 'package:ost_flutter_module/widget/loading/loading_view.dart';

import 'completable_action.dart';

class BaseRequestListModel<T> {
  final int pageIndex;
  final LoadingStatus loadingStatus;
  final bool isLastPage;
  final String errorMsg;

  final List<T> dataList;

  BaseRequestListModel(
      {this.pageIndex = 1,
      this.loadingStatus = LoadingStatus.loading,
      this.isLastPage = false,
      this.errorMsg,
      this.dataList = const []});

  BaseRequestListModel<T> copyWith(
      {int pageIndex,
      LoadingStatus loadingStatus,
      bool isLastPage,
      String errorMsg,
      List<T> dataList}) {
    return BaseRequestListModel<T>(
        pageIndex: pageIndex ?? this.pageIndex,
        loadingStatus: loadingStatus ?? this.loadingStatus,
        isLastPage: isLastPage ?? this.isLastPage,
        errorMsg: errorMsg ?? this.errorMsg,
        dataList: dataList ?? this.dataList);
  }
}

class BaseRequestModel<T> {
  final LoadingStatus loadingStatus;
  final CompletableAction action;
  final String errorMsg;
  final T entity;

  BaseRequestModel(
      {this.loadingStatus = LoadingStatus.loading,
      this.action,
      this.errorMsg,
      this.entity});

  BaseRequestModel<T> copyWith(
      {LoadingStatus loadingStatus,
      CompletableAction action,
      String errorMsg,
      T entity}) {
    return BaseRequestModel<T>(
        loadingStatus: loadingStatus ?? this.loadingStatus,
        action: action ?? this.action,
        errorMsg: errorMsg ?? this.errorMsg,
        entity: entity ?? this.entity);
  }
}
